<template>
  <div class="header">
    <div class="container">
      <!-- logo -->
      <div class="logo">
        <img src="../assets/logo.png" width="40px" alt="" />
        <a href="javascript:void(0);">橙子博客</a>
      </div>
      <!-- 导航 -->
      <div class="nav">
        <ul>
          <li :class="route === '/main' ? 'active' : ''">
            <a href="/main">首页</a>
          </li>
          <li :class="route === '/resources' ? 'active' : ''">
            <a href="/resources">下载·课程</a>
          </li>
          <li :class="route === '/certificate' ? 'active' : ''">
            <a href="/certificate">认证</a>
          </li>
          <li :class="route === '/community' ? 'active' : ''">
            <a href="/community">社区</a>
          </li>
          <li :class="route === '/special' ? 'active' : ''">
            <a href="/special">专题</a>
          </li>
        </ul>
      </div>
      <div class="search">
        <input type="text" class="input" placeholder="想搜点什么呢.." />
        <i class="el-icon-search"></i>
      </div>
      <!-- 用户 -->
      <div class="user">
        <ul>
          <li>
            <div class="user-img">
              <!-- <a href="javaScript:void(0);">登录/注册</a> -->
              <el-popover placement="bottom" width="200" trigger="hover">
                <div class="user-menu-top">橙子娱乐</div>
                <div class="user-menu-bottom">
                  <ul>
                    <li v-for="(item, index) in userMenu" :key="index">
                      <a :href="item.menuUrl">
                        <i :class="item.icon"></i>
                        {{ item.title }}
                      </a>
                    </li>
                    <li>
                      <a href="/logout">
                        <i class="iconfont icon-tuichu"></i>
                        退出
                      </a>
                    </li>
                  </ul>
                </div>
                <el-avatar slot="reference">橙子</el-avatar>
              </el-popover>
            </div>
          </li>
          <li>
            <a href="javaScript:void(0);">足迹</a>
          </li>
          <li>
            <a href="javaScript:void(0);">消息</a>
          </li>
          <li>
            <a href="/creation" class="btn">
              <i class="el-icon-edit"></i>
              创作
            </a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
// 首页
export default {
  name: 'Header',
  data() {
    return {
      userMenu: [
        {
          menuUrl: '/user-center',
          icon: 'el-icon-user',
          title: '个人中心'
        },
        {
          menuUrl: '/creation',
          icon: 'el-icon-document',
          title: '内容管理'
        },
        {
          menuUrl: 'javascript:void(0);',
          icon: 'el-icon-s-order',
          title: '我的订单'
        },
        {
          menuUrl: 'javascript:void(0);',
          icon: 'el-icon-wallet',
          title: '我的钱包'
        },
        {
          menuUrl: 'javascript:void(0);',
          icon: 'el-icon-medal',
          title: '我的认证'
        }
      ]
    }
  },
  computed: {
    route() {
      return this.$route.path
    }
  }
}
</script>

<style lang="less" scoped>
.header {
  height: 60px;
  box-shadow: 0px 5px 10px #b2b2b2b2;
  .container {
    display: flex;
    justify-content: space-between;
  }
  .logo {
    display: flex;
    align-items: center;
    height: 60px;
    width: 120px;
    a {
      font-size: 20px;
      font-weight: bold;
      color: #006cff;
    }
  }
  .nav {
    width: 400px;
    height: 60px;
    line-height: 60px;
    ul {
      display: flex;
      justify-content: space-around;
    }
  }
  .search {
    width: 300px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    .input {
      border: none;
      outline: none;
      height: 30px;
      line-height: 30px;
      z-index: 10;
      font-size: 16px;
      color: #333;
      background: none;
      border-bottom: 1px solid #dcdfe6;
      background: #fff;
      width: 200px;
      padding-left: 10px;
      padding-right: 20px;
    }
    i {
      margin-left: -20px;
    }
  }
  .user {
    width: 290px;
    height: 60px;
    line-height: 60px;
    .user-img {
      display: flex;
      align-items: center;
    }
    ul {
      display: flex;
      justify-content: space-around;
      align-items: center;
    }
    .btn {
      width: 70px;
      height: 30px;
      border: 1px #1877fd solid;
      border-radius: 20px;
      background: #006cff;
      color: #fff;
      padding: 5px 20px;
      i {
        color: #fff;
      }
    }
  }
}
.active {
  border-bottom: 4px solid #006cff;
  font-weight: bold;
  a {
    color: #006cff;
  }
}
.el-avatar {
  vertical-align: middle;
}
.user-menu-top {
  text-align: center;
  padding: 12px 0px;
  font-size: 16px;
  border-bottom: 1px solid #e8e8ed;
}
.user-menu-bottom {
  padding: 10px 0px;
  li {
    height: 40px;
    line-height: 40px;
    padding: 0px 10px;
  }
}
</style>
